////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file   CollabRCBot\DivisionOperationTreeNode.h
///
/// @brief  Declares the implementation of a CollabRC::Bot::AI::OperationTreeNode for division
////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "OperationTreeNode.h"

namespace CollabRC
{
    namespace Bot
    {
        namespace AI
        {
            /**
             * @brief Implementation of a CollabRC::Bot::AI::OperationTreeNode
             * which handles division.
             *
             * The operation will fail if an attempt is made to divide by zero.
             * @version $Id$
             * @author Matthew P. Del Buono
             */
            class DivisionOperationTreeNode : public OperationTreeNode
            {
            private:
                class Factory : public OperationTreeNodeFactory
                {
                public:
                    inline Factory() { OperationTreeNode::RegisterOperationTreeNodeFactory(this); };
                    ComputationalTreeNode* Instantiate(const ComputationalTreeNode& lhs, const ComputationalTreeNode &rhs) const;
                };

                static Factory factory;
            public:
                DivisionOperationTreeNode(const ComputationalTreeNode& lhs, const ComputationalTreeNode& rhs);
                DivisionOperationTreeNode(const OperationTreeNode& copy);
                virtual ~DivisionOperationTreeNode(void);

                virtual float PerformOperation(float lhs, float rhs) const;
                virtual ComputationalTreeNode* Clone() const;
                virtual void Accept(ComputationalTreeNodeVisitor& visitor);
            };
        }
    }
}